package UserAppConf

import (
	"github.com/spf13/viper"
	"github.com/zeromicro/go-zero/core/logx"
)

type AppConfig struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Addr     string
		Password string
		Db       int
	}
}

var AppConf AppConfig

func Init() {
	viper.SetConfigFile("./UserAppConf/UserAppConf.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		logx.Error("配置文件读取失败")
	}
	err = viper.Unmarshal(&AppConf)
	if err != nil {
		logx.Error("配置文件解析失败")
	}
	logx.Info("配置文件解析成功")
}
